package com.example.demo.service;

import com.example.demo.entity.UserInfo;
import com.example.demo.mapper.UserMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

@Service
public class UserService {

    private static UserMapper userMapper;
    @Resource
    public void setUserMapper(UserMapper userMapper) {
        UserService.userMapper = userMapper;
    }


    public int reg(UserInfo userInfo){
        userMapper.reg1(userInfo);
        return userMapper.reg(userInfo);
    }

    public static int addErr(String username){
        return userMapper.addErr(username);
    }

    public static int rCount(String username){
        return userMapper.rCount(username);
    }

    public static int lockUser(String username){
        return userMapper.lockUser(username);
    }

    public void changePassword(Integer id, String password){
        userMapper.changePassword(id,password);
    }

    public void unlockUser(String username){
        userMapper.unlockUser(username);
    }

    public UserInfo getUserByName(String username) {
        return userMapper.getUserByName(username);
    }

    public UserInfo getUserById(Integer id){
        return userMapper.getUserById(id);
    }
}
